<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('流量监控列表')"/>
    <th:block th:include="include :: select2-css"/>
    <th:block th:include="include :: bootstrap-select-css"/>
</head>
<body class="gray-bg">
<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <form id="online-form">
                <div class="select-list">
                    <ul>
                        <li>
                            使用单位：<select id="useCompany" name="useCompany" class="form-control">
                            <option value="">--请选择使用单位--</option>
                        </select>
                        </li>
                        <li>
                            流量状态：<select id="state" name="state" class="form-control"></select>
                        </li>
                        <li>
                            SIM卡号：<input type="text" name="cardNo" id="cardNo"
                                         onkeyup="value=value.replace(/[^\d]/g,'')"
                                         maxlength=11 autocomplete="off"/>
                        </li>
                        <li>
                            月流量：<input id="monthFlow1" type="text" name="monthFlow1" style="width: 80px;"
                                       onkeyup="value=value.replace(/[^\d]/g,'')" maxlength=8 autocomplete="off"/>&nbsp;—&nbsp;
                            <input id="monthFlow2" type="text" name="monthFlow2" style="width: 80px;"
                                   onkeyup="value=value.replace(/[^\d]/g,'')" maxlength=8 autocomplete="off"/>
                        </li>
                        <li>
                            <a class="btn btn-primary btn-rounded btn-sm" onclick="select()"><i
                                    class="fa fa-search"></i>&nbsp;搜索</a>
                            <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i
                                    class="fa fa-refresh"></i>&nbsp;重置</a>
                        </li>
                    </ul>
                </div>
            </form>
        </div>

        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table"></table>
        </div>
    </div>
</div>
<th:block th:include="include :: footer"/>
<th:block th:include="include :: bootstrap-table-export-js"/>
<th:block th:include="include :: select2-js"/>
<th:block th:include="include :: bootstrap-select-js"/>
<script th:inline="javascript">
    var forceFlag = [[${@permission.hasPermi('monitor:online:forceLogout')}]];
    var prefix = ctx + "base_card";

    $(document).ready(function () {

    });

    function select() {
        var num1 = $("#monthFlow1").val();
        var num2 = $("#monthFlow2").val();
        if (parseInt(num2) < parseInt(num1)) {
            $.modal.alertError('请输入正确的流量区间');
            return
        }
        $.table.search()
    }

    $(function () {

        $.ajax({
            type: "GET",
            url: '/data_info/getCompany',
            dataType: "json",
            success: function (data) {
                $('#useCompany').select2({
                    data: data
                })
            },
            error: function (jqXHR) {
                console.log("Error: " + jqXHR.status);
            }
        });

        // $('#useCompany').select2({
        //     data: [{id: "1", text: "11", selected: false, disable: true}]
        // })
        $('#state').select2({
            data: [
                {id: "0", text: "全部"},
                {id: "1", text: "正常"},
                {id: "5", text: "零流量"},
                {id: "6", text: "超流量"}
            ]
        })

        var options = {
            url: prefix + "/list",
            sortOrder: "desc",
            showFooter: false,
            showSearch: false,
            showRefresh: true,
            showToggle: false,
            showColumns: false,
            escape: false,
            columns: [
                {
                    title: "序号",
                    formatter: function (value, row, index) {
                        return $.table.serialNumber(index);
                    }
                },
                {
                    field: 'cardNo',
                    title: 'SIM卡号',
                    // sortable: true
                },
                {
                    field: 'companyName',
                    title: '使用单位'
                },
                {
                    field: 'userName',
                    title: '安装地点'
                },
                {
                    field: 'businessName',
                    title: '业务应用'
                },
                {
                    field: 'browser',
                    title: '本月已使用流量（M）'
                },
                {
                    field: 'os',
                    title: '流量套餐（M  ）'
                },
                {
                    field: 'startTimestamp',
                    title: '流量状态',
                },
                // {
                //     title: '操作',
                //     align: 'center',
                //     formatter: function (value, row, index) {
                //         var msg = '<a class="btn btn-danger btn-xs ' + forceFlag + '" href="javascript:void(0)" onclick="forceLogout(\'' + row.sessionId + '\')"><i class="fa fa-sign-out"></i>强退</a> ';
                //         return msg;
                //     }
                // }
            ]
        };
        $.table.init(options);
    });

</script>
</body>
</html>